<?php 
    include("header.php");
?>

<head>
    <title>Liga - Nieuws</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="assets/css/default.css" rel="stylesheet" type="text/css">

    
    <style type="text/css">

        @import "/assets/js/dojo-release-1.1.0/dijit/themes/tundra/tundra.css";

    </style>
    
    <!--
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js" type="text/javascript"></script>
    -->
    <!--<script type="text/javascript" src="/assets/js/dojo-release-1.1.0/dojo/dojo.js"
      djConfig="parseOnLoad: true"></script>-->
    
    <script type="text/javascript">
        dojo.require("dijit.Dialog");
        dojo.require("dijit.form.TextBox");
        dojo.require("dijit.form.Button");
    </script>

</head>

<?php
    setTabIndex(1);
    createBody("default");
    
    if ( isset($_SESSION['user']) ) $user = $_SESSION['user'];
    
    mysql_connect(DB_SERVER, DB_USER, DB_PWD);
    mysql_select_db(DB_CATALOG);
    $result = mysql_query("SELECT ni.news_id, ni.title, ni.introImage, DATE_FORMAT(nh.news_date,'%e/%m/%Y %k:%i:%s') AS date, 
        ni.intro, ni.message, u.username, u.function FROM news_item AS ni, news_history AS nh, user AS u 
        WHERE ni.news_id = nh.news_id AND nh.user_id = u.user_id
        AND DATEDIFF(CURDATE(),nh.news_date) <= 90
        ORDER BY ni.news_id DESC");

    $newsItems = array();
    while ($row = mysql_fetch_assoc($result)) {
        if (!isset($newsId) || $newsId != $row['news_id']) {
            $newsId = $row['news_id'];
            $newsItem = new NewsItem;
            $newsItem->news_id = $row['news_id'];
            $newsItem->title = $row['title'];
            $newsItem->date = $row['date'];
            $newsItem->intro = $row['intro'];
            $newsItem->introImage = $row['introImage'];
            $newsItem->message = $row['message'];
            $newsItem->username = $row['username'];
            $newsItem->function = $row['function'];
            if ( isValidURL($newsItem->introImage) ) {
                $newsItem->intro = "<table><tr valign=top><td><img src=".$newsItem->introImage." height=60 /></td><td>".$row['intro']."</td></tr></table>";
            }
            array_push($newsItems, $newsItem);
        }
    }
?>

<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0" bgcolor="#FFFFFF">

    <tr>
        <td id="leftFiller" valign="top" height="100%" rowspan="3" bgcolor="#006633">
            <table border="0" cellpadding="0" cellspacing="0" height="100%" width="8px">
                <tr><td>&nbsp;</td></tr>
            </table>
        </td>
        <td id="header" valign="top" width="100%">
            <table border="0" width="100%" cellpadding="3" cellspacing="0" bgcolor="#10425b">
                <tr>
                    <td bgcolor="#006633" width="70%">
                        <?php include("inc_title.html"); ?>
                    </td>
                    <td bgcolor="#006633" align="right">&nbsp;
                    </td>
                </tr>
            </table>
            <table align="center" border="0" width="100%" height="90%" cellpadding="0" cellspacing="0" style="border-top:#BCDD10 4px solid;">
                <tr>
                    <?php include("inc_sublinks.php"); ?>   
                </tr>
                <tr><td colspan="4" nowrap bgcolor="#BCDD10" height="4"><img src="/assets/images/spacer.gif" alt="" height="1" width="1"></td></tr>
                <tr>
                    <td>&nbsp;</td>
                    <td width="75%" valign="top">
                        <table cellspacing="2" cellpadding="5" class="newsbox">
                            <?php
                                $link = "";
                                foreach ($newsItems as $item) {
                                    $ref = "news_detail.php?newsId=".$item->news_id;

                                    if ( isset($user) && ( strnatcasecmp($user->name, $item->username) == 0 || $user->club_id == 100)) {
                                        $link = "<span class='newsAdmin'><a href='edit_news_form.php?news_id=$item->news_id'>Editeer</a></span>". 
                                                "<span class='newsAdmin'><a href='news_delete.php?news_id=$item->news_id'>Verwijder</a></span>";
                                                
                                    } else {
                                         $link = "";
                                    }
                            ?>
                            <tr>
                                <td valign="top" style="border-bottom:1px dashed #999999;width:95%;">
                                    <span class="newsTitle"><a href="<?=$ref?>"><?=$item->title?></a></span>
                                    
                                    <?=$link?><br/>
                                    
                                    <span class="newsDate">Gepost door: <em><?=$item->username?></em> op <?=$item->date?></span><br/><?=$item->intro?>
                                </td>
                            </tr>
                            <?php
                                }
                            ?>
                        </table>
                    </td>
                    <td width="20%" valign="top">
                    <br/>
                    <script src="http://widgets.twimg.com/j/2/widget.js"></script>
                    <script>
                    new TWTR.Widget({
                      version: 2,
                      type: 'profile',
                      rpp: 4,
                      interval: 6000,
                      width: 'auto',
                      height: 300,
                      theme: {
                        shell: {
                          background: '#FFFF99',
                          color: '#030303'
                        },
                        tweets: {
                          background: '#ffffff',
                          color: '#080808',
                          links: '#f21137'
                        }
                      },
                      features: {
                        scrollbar: true,
                        loop: false,
                        live: true,
                        hashtags: true,
                        timestamp: true,
                        avatars: false,
                        behavior: 'all'
                      }
                    }).render().setUser('schaakliga100').start();
                    </script>
                    <br/>&nbsp;<br/>
                    <iframe src="http://www.google.com/calendar/embed?showPrint=0&amp;showTabs=0&amp;mode=AGENDA&amp;height=300&amp;wkst=2&amp;hl=nl&amp;bgcolor=%23FFFFFF&amp;src=06pgoud782d298q15ogja4ca74%40group.calendar.google.com&amp;color=%23060D5E&amp;ctz=Europe%2FBrussels" style=" border-width:0 " width="400" height="300" frameborder="0" scrolling="no"></iframe>
                    </td>
                    <td width="5%">&nbsp;</td> 
                </tr>
                <tr><td colspan="4">&nbsp;</td></tr>
                <tr>
                    <td colspan="4" style="color:#666666;background-color:#DDDDDD">
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <a target="_blank"  href="http://www.provant.be/sport" border="0"><img alt="met de steun van de provincie antwerpen" 
                            height="40" border="0" src="/assets/images/provincie_antwerpen.jpg" /></a></label>
                        &nbsp;&nbsp;&nbsp;&nbsp;Met de steun van de <a target="_blank" href="http://www.provant.be/sport" border="0">Provincie Antwerpen</a>.
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
    
<!--
<div dojoType="dijit.Dialog" id="deleteDialog" class="tundra" title="Bevestiging">
    <table >
        <tr>
            <td colspan="2"><label>Bent u zeker dat u dit nieuwsbericht wil verwijderen?</label></td>
        </tr>
        <tr>
            <td align="center">
                <button class="tundra" dojoType="dijit.form.Button" type="submit" id="yes">Ja</button>
            </td>
            <td align="center">
                <button class="tundra" dojoType="dijit.form.Button" type="submit" id="no">Nee</button>
            </td>
        </tr>
    </table>
</div>
-->
<?php include("footer.php") ?>